<template>
    <div class="header">
        <h1 class="title">
            {{ title }}
            <span class="sub-title">{{ subtitle }}</span>
        </h1>
        <div class="header-actions">
            <el-button type="default" @click="handleRefresh">
                刷新
                <svg-icon :icon-class="'refresh'" size="10"></svg-icon>
            </el-button>
            <el-button type="default" @click="handleExport" v-if="showExportBtn">
                导出
                <svg-icon :icon-class="'export'" size="10"></svg-icon>
            </el-button>
        </div>
    </div>
</template>

<script>
export default {
    name: 'headerTitle',
    props: {
        title: {
            type: String,
            required: true,
            default: 'title',
        },
        subtitle: {
            type: String,
            default: '',
        },
        showExportBtn: {
            type: Boolean,
            default: true,
        },
    },
    methods: {
        handleExport() {
            this.$emit('export');
        },
        handleRefresh() {
            this.$emit('refresh');
        },
    },
};
</script>

<style lang="scss" scoped>
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 10px;

    .title {
        font-size: 24px;
        font-weight: bold;
        color: #333;
        margin: 0;
    }
    .sub-title {
        font-size: 22px;
        color: #333;
        margin-left: 12px;
    }
    .header-actions {
        display: flex;
        gap: 10px;

        ::v-deep .el-button > span {
            display: flex;
            align-items: center;

            svg {
                margin-left: 6px;
            }
        }
    }
}
</style>
